<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<div class="t_bar">
	<span class="color_red">*</span>项目建设目标
	<span style="font-size: 12px;font-weight: normal;">
		（总投入资金，包括已完成投资及新增投资，金额单位：万元）
	</span>
</div>
	<table  id="milestone_edit" border="0" cellspacing="0" cellpadding="0" class="table01" >
		<thead>
			<tr>
                <th width="50px" >选择</th>
                <th nowrap width="50px" >序号</th>
				<th width="200px">建设阶段</th>
				<th width="100px">人员费</th>
				<th width="100px">仪器设备费</th>
				<th width="100px">外协费用</th>
				<th width="100px">其他费用</th>
				<th width="100px" nowrap="nowrap">小计</th>
				
			</tr>
		</thead>
		<tbody id="tab">
			<tr style="display: none">
				<td  align="center"  width="50px" >
					<input type="radio" class="radiobutton" name="selMilestone_edit" >
				</td>
				<td align="center">
					<span name="milestones|milestone[0]@seq_no">[index]</span>
					<input type="hidden" name="milestones|milestone[0]|content">
					<input type="hidden" name="milestones|milestone[0]|content_hidden">
					<input type="hidden" name="milestones|milestone[0]|equipments"  label="xml">
				</td>
				<td align="center">
					<span name="milestones|milestone[0]|start_date"></span> 至 <span name="milestones|milestone[0]|end_date"></span>
				</td>
				<td>
					<span name="milestones|milestone[0]|personnel_costs"></span>
				</td>
				<td>
					<span name="milestones|milestone[0]|equipment|equipments|equipment_total_costs"></span>
				</td>
				<td>
					<span name="milestones|milestone[0]|outsourcing_costs"></span>
				</td>
				<td>
					<span name="milestones|milestone[0]|other_costs"></span>
				</td>
				<td>
					<span name="milestones|milestone[0]|total_costs" ></span>
				</td>
				
			</tr>
			<c:set value="0" var="index" scope="page" />
			<x:forEach select="$xmlData/data/milestones/milestone" var="milestone">
				<c:choose>
					<c:when test="${index<10}">
						<c:set value="0" var="flag" scope="page" />
					</c:when>
					<c:otherwise>
						<c:set value="" var="flag" scope="page" />
					</c:otherwise>
				</c:choose>
				<tr>
					<td  align="center"  width="50px" >
						<input type="radio" name="selMilestone_edit"/> 
						<input type="hidden" name="milestones/milestone[${flag}${index}]/content" value="<x:out select="$milestone/content" />" />
						<input type="hidden" name="milestones/milestone[${flag}${index}]/content_hidden" value="<x:out select="$milestone/content_hidden" />" />
						<input type="hidden" name="milestones/milestone[${flag}${index}]/equipments" value="" label="xml"/>
						
					</td>
					<td align="center">
						<span name="milestones/milestone[${flag}${index}]@seq_no"><x:out select="$milestone/@seq_no"/></span>
					</td>
					<td align="center">
						<span name="milestones/milestone[${flag}${index}]/start_date"><x:out select="$milestone/start_date" /></span> 至 <span name="milestones/milestone[${flag}${index}]/end_date"><x:out select="$milestone/end_date" /></span>
					</td>
					<td>
						<span name="milestones/milestone[${flag}${index}]/personnel_costs"><x:out select="$milestone/personnel_costs" /></span>
					</td>
					<td>
						<span name="milestones/milestone[${flag}${index}]/equipment/equipments/equipment_total_costs"><x:out select="$milestone/equipment/equipments/equipment_total_costs" /></span>
					</td>
					<td>
						<span name="milestones/milestone[${flag}${index}]/outsourcing_costs"><x:out select="$milestone/outsourcing_costs" /></span>
					</td>
					<td>
						<span name="milestones/milestone[${flag}${index}]/other_costs"><x:out select="$milestone/other_costs" /></span>
					</td>
					<td>
						<span name="milestones/milestone[${flag}${index}]/total_costs"><x:out select="$milestone/total_costs" /></span>
					</td>
					
				</tr>
				<c:set value="${index+1}" var="index" scope="page" />
			</x:forEach>
			</tbody>
	</table>
<br>

	<table border="0" cellpadding="0" cellspacing="1">
		<tr>
			<td>
				<input class="button_02" type="button" value="添加" onclick="if(checkTabLimit('milestone_edit',10,'项目建设目标最多只能填写10条')){addNewRow('milestone_edit','${ctx}/proposal/edit/dialog/prpMilestonesInfoEdit_cxzj?parentTab=milestone_edit&type=add&needMeetingInfo=${param.needMeetingInfo}&TB_iframe=true&height=440&width=680','添加项目计划');}try{top.resizeFrame();}catch(e){};">
				&nbsp;<input class="button_02"  id="zh_psnPrev" type="button" value="上移" onclick="movePrev('milestone_edit','selMilestone_edit');">
				&nbsp;<input class="button_02"  id="zh_psnNext" type="button" value="下移" onclick="moveNext('milestone_edit','selMilestone_edit');">
				&nbsp;<input class="button_02"  id="zh_psnEdit" type="button" value="编辑" onclick="editRow('milestone_edit','${ctx}/proposal/edit/dialog/prpMilestonesInfoEdit_cxzj?parentTab=milestone_edit&type=edit&needMeetingInfo=${param.needMeetingInfo}&TB_iframe=true&height=440&width=680','编辑项目计划信息')">
				&nbsp;<input class="button_02"  id="zh_psnDel" type="button" value="删除" onclick="deleteSelectedRow('milestone_edit','项目建设目标');"></td>
		</tr>
	</table>
<textarea id="xmlStr" style="display: none" >${param.xmlstr}</textarea>
	
<script type="text/javascript">
	showAllDateTag("milestone_edit");
	$(function(){
		
		//将申请书xml中的研究领域xml字符串设置到每个设备的对应隐藏域
		setEquipment("milestone_edit", "xmlStr");

	});
	
	
	function setEquipment(tblId, xmlId, nodeName){
		var xmlStr = $.trim($("#"+xmlId).val());
		
		if(xmlStr==null || xmlStr=="")
			return false;
		var reg = /[\r\n]/g;
		xmlStr=xmlStr.replace(reg,""); 
		var milestonesNode = /<milestones(.\n?)+?<\/milestones>/g;
		var milestones = xmlStr.match(milestonesNode);
		if(milestones==null || !milestones.length ||milestones.length==0)return;
		var milestoneNode = /<milestone[^s](.\n?)+?<\/milestone>/g;
		var milestone = milestones[0].match(milestoneNode);
		
		if(milestone != null){
			$("#"+tblId+" tr:gt(1)").each(function(i,obj){
				if(milestone[i]!=null){
					var equipments = milestone[i].match(/<equipments(.\n?)+?<\/equipments>/);
					if(equipments!=null){
						var str = equipments[0].replace(/<equipments.*?>|<\/equipments>/g,"");
						$(obj).find("[name$='/equipments']").val(str);
						
					}
				} 
				
			});
		}
	}
</script>